import requests
from requests.exceptions import RequestException


def test_001():
    url = "http://127.0.0.1:8088/futureloan/mvc/api/loan/add"
    cs = {
        "memberId": 1,  # 假设的用户ID，正整数
        "title": "新房装修",  # 借款标题
        "amount": 5000.00,  # 借款金额，大于等于1000且能被100整除的正整数，这里为5000元
        "loanRate": 15.0,  # 年利率，如年化18.0%，存储为18.0
        "loanTerm": 6,  # 借款期限，如6个月
        "loanDateType": 2,  # 借款期限类型，0-按月
        "repaymemtWay": 4,  # 还款方式，4-一次性
        "biddingDays": 5  # 竞标天数，介于1-10天之间
    }
    r = requests.post(url, data=cs, timeout=5)

    a = r.json()
    print(a)
    # 断言检查
    assert a['status'] == 1
    assert a['code'] == '10001'
    assert a['msg'] == '加标成功'


# 运行测试
if __name__ == "__main__":
    test_001()
